﻿Imports System
Imports System.Drawing

Namespace System.Workflow.ComponentModel.Design
    Friend NotInheritable Class ConnectionPointGlyph
        Inherits DesignerGlyph
        ' Methods
        Friend Sub New(ByVal connectionPoint As ConnectionPoint)
            Me.connectionPoint = connectionPoint
        End Sub

        Protected Overrides Sub OnPaint(ByVal graphics As Graphics, ByVal activated As Boolean, ByVal ambientTheme As AmbientTheme, ByVal designer As ActivityDesigner)
            If (((Not designer.Activity Is Nothing) AndAlso (Not designer.Activity.Site Is Nothing)) AndAlso (Not Me.connectionPoint Is Nothing)) Then
                Dim service As WorkflowView = [TryCast](designer.Activity.Site.GetService(GetType(WorkflowView)),WorkflowView)
                Dim viewPort As Rectangle = If((Not service Is Nothing), service.ViewPortRectangle, Rectangle.Empty)
                Dim clipRectangle As Rectangle = If((Not designer.ParentDesigner Is Nothing), designer.ParentDesigner.Bounds, designer.Bounds)
                Dim manager As ConnectionManager = [TryCast](designer.Activity.Site.GetService(GetType(ConnectionManager)),ConnectionManager)
                Dim e As New ActivityDesignerPaintEventArgs(graphics, clipRectangle, viewPort, designer.DesignerTheme)
                Dim drawHighlighted As Boolean = ((Not manager Is Nothing) AndAlso Me.connectionPoint.Equals(manager.SnappedConnectionPoint))
                Me.connectionPoint.OnPaint(e, drawHighlighted)
            End If
        End Sub


        ' Properties
        Public Overrides ReadOnly Property Priority As Integer
            Get
                Return 1
            End Get
        End Property


        ' Fields
        Private connectionPoint As ConnectionPoint
    End Class
End Namespace

